package com.example.administrator.myapplication

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.MotionEvent
import android.R.attr.startY
import android.widget.Toast
import com.example.administrator.myapplication.widget.ArrowView
import com.example.administrator.myapplication.widget.GraffitiView
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {
    private var startX:Float?=null
    private var startY:Float?=null
    private var status:Int=0;

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
    }

    private fun initView() {
        GraffitiView(this).setFilePath("/res/drawable/background")
        GraffitiView(this).setDrawType(status)
        button.setOnClickListener {
            status++
            GraffitiView(this).setDrawType(status)
        }
    }

//    override fun onTouchEvent(event: MotionEvent): Boolean {
//        when (event.action) {
//            MotionEvent.ACTION_DOWN -> {
//                //记下按下去的初始位置，actionbarHeight和statusHeight是toolBar和状态栏的高度
//                startX = event.getX()
//                startY = event.getY()
//                return true
//            }
//            MotionEvent.ACTION_MOVE -> {
//                val moveX = event.x
//                val moveY = event.y
//                ArrowView(this).clear() //每次移动的时候都先清空一次path
//                ArrowView(this).setPath(this!!.startX!!, this!!.startY!!, moveX, moveY)  //将2个点的位置传给arrowView
//                Toast.makeText(this,"画",Toast.LENGTH_SHORT).show()
//            }
//            MotionEvent.ACTION_UP -> {
//
//            }
//            else -> {
//            }
//        }
//        return super.onTouchEvent(event)
//    }
}
